﻿@{
    ViewBag.Title = "微信支付";
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.PathToBtn = "/Charge/Index";
    ViewBag.TextBtn = "刷新";
}
@section javascript{
    <script type="text/javascript">
        $("#ContentHeadBtn").hide();
        var JsApiParam = eval("(" + $("#hidWxJsApiParam").val() + ")");
        //调用微信JS api 支付
        function jsApiCall() {
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest',
                JsApiParam,//josn串
                function (res) {
                    WeixinJSBridge.log(res.err_msg);
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        location.href = "/Charge/Success";
                    } else {
                        location.href = "/Charge/PayFail";
                    }
                }
            );
        }
        function callpay() {
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                }
                else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            }
            else {
                jsApiCall();
            }
        }
    </script>
}
<form>
    <br />
    <div align="center">
        <br /><br /><br />
        <span>本次支付<b style="color:red;font-size:18px;margin-left:5px;">¥@ViewBag.Money</b></span><br /><br />
        <input type="button" value="立即支付" onclick="callpay()" class="btn btn-primary" />
        <input type="hidden" value="@ViewBag.WxJsApiParam" id="hidWxJsApiParam" />
    </div>
</form>
